package com.bys.admin.system.controller;


import com.bys.response.R;
import com.bys.admin.system.entity.SysDataResource;
import com.bys.admin.system.service.ISysDataResourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import jakarta.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 数据源配置 前端控制器
 * </p>
 *
 * @author bys
 * @since 2025-02-20
 */
@Tag(name = "数据源配置接口")
@RestController
@RequestMapping("/system/sys-data-resource")
public class SysDataResourceController {
    @Resource
    private ISysDataResourceService sysDataResourceService;

    @GetMapping("/list")
    @Operation(summary="查询数据源列表")
    public R<List<SysDataResource>> list(){
        return R.success(sysDataResourceService.getDataResourceList());
    }

    @Operation(summary="保存数据源")
    @PostMapping("/save")
    @Transactional(rollbackFor = Exception.class)
    public R<Boolean> save(@RequestBody SysDataResource sysDataResource){
        sysDataResourceService.save(sysDataResource);
        return R.success(Boolean.TRUE);
    }


}
